package InterFaceContact;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;

public class Trafic {
	static HashMap<String, HashMap<String, ArrayList<Request>>> config = new HashMap<String, HashMap<String, ArrayList<Request>>>();
	
	public static void geraPares (HashMap<String, HashMap<String, Link>> topologia){
		Iterator<String> it = topologia.keySet().iterator();
		Iterator<String> it2;
		String nomeit1 = new String();
		String nomeit2 = new String();
		
		while(it.hasNext()){
			nomeit1 = it.next();
			it2 = topologia.keySet().iterator();
			config.put(nomeit1, new HashMap<String, ArrayList<Request>>());
			
			while(it2.hasNext()){
				nomeit2 = it2.next();
				
				if(!nomeit1.equals(nomeit2))
					config.get(nomeit1).put(nomeit2, new ArrayList<Request>());
			}
		}
	}
	
	public static void setaTodasRequisicoesPadrao(Request req){
		Iterator<String> it = config.keySet().iterator();
		Iterator<String> it2;
		String nomeit1 = new String();
		String nomeit2 = new String();
		
		
		while(it.hasNext()){
			nomeit1 = it.next();
			it2 = config.get(nomeit1).keySet().iterator();
			
			while(it2.hasNext()){
				nomeit2 = it2.next();
				for (Request request : config.get(nomeit1).get(nomeit2)) {					
					request.setArrive(req.getArrive());
					request.setAtend(req.getAtend());
					request.setIncr(req.getIncr());
					request.setSize(req.getSize());
				}
			}
			
		}
	}
	
	public static void setConfig(HashMap<String, HashMap<String, ArrayList<Request>>> config){
		Trafic.config = config;
	}

	public static HashMap<String, HashMap<String, ArrayList<Request>>> getConfig() {
		return config;
	}

}
